< previous page page_445 next page >

Page 445
You can resize the form and the graph resizes too. You can also use the menu on the graph to print, save, or copy the graph to the Clipboard.
Now add the Sales by Month graph to the project. This time, you want a line graph that shows the total sales by month. First, you need to construct the SQL statement. It should look like the following:
SELECT Month, SUM(Amount) AS SalesTotal
   FROM SalesData
   WHERE CompanyName<>'Budget'
   GROUP BY Month;
Now open the mnuGraphsItem_Click event and add the code in Listing 11.30.
Type.gifListing 11.30. Adding the code for the mnuGraphsMonthItem_Click event.
Private Sub mnuGraphsItem_Click(Index As Integer)
    '
    ' handle graph menu requests
    '
    Dim objDG As New DataGraph
    Dim strSQL As String
    '
    Select Case Index
        Case 0 ' sales by region
            '
            strSQL = "SELECT Region, SUM(Amount) AS SalesTotal FROM "
            strSQL = strSQL & "SalesData WHERE CompanyName<>'Budget' GROUP BY
            arrow.gifRegion"
            '
            objDG.DatabaseName = Data1.DatabaseName
            objDG.SQLSelect = strSQL
            objDG.GraphType = dgPie3d
            objDG.GraphField = "SalesTotal"
            objDG.GraphTitle = "Sales by Region"
            objDG.LegendField = "Region"
            '
        Case 1 ' sales by month
            '
            strSQL = "SELECT Month, SUM(Amount) AS SalesTotal FROM "
            strSQL = strSQL & "SalesData WHERE CompanyName<>'Budget' GROUP BY
            arrow.gifMonth"
            '
            objDG.DatabaseName = Data1.DatabaseName
            objDG.SQLSelect = strSQL
            objDG.GraphType = dgLine
            objDG.GraphField = "SalesTotal"
            objDG.LabelField = "Month"
            objDG.GraphTitle = "Sales by Month"
            objDG.LeftTitle = "($)"
continues

 
< previous page page_445 next page >

If you like this book, buy it!